/**
 * ASt Transformer.
 */
class Transformer {
  /**
   * Translates `def` - expression (function delaration)
   * into a variable declaration with a lambda expression
   */
  transformDefToLambada(defExp) {
    const [_tag, name, params, body] = defExp;

    // JIT-transpile to a varibale declaration
    const varExp = ["var", name, ["lambda", params, body]];

    return varExp;
  }

  /**
   * Transforms `switch` to nested `if` -expressions.
   */
  transformerSwitchToIf(switchExp) {
    const [_tag, ...cases] = switchExp;
    const ifExp = ["if", null, null, null];
    let current = ifExp;
    for (let i = 0; i < cases.length - 1; i++) {
      const [currentCond, currentBlock] = cases[i];
      current[1] = currentCond;
      current[2] = currentBlock;

      const next = cases[i + 1];

      const [nextCond, nextBlock] = next;

      current[3] = nextCond === "else" ? nextBlock : ["if"];

      current = current[3];
    }
    return ifExp;
  }

  /**
   *
   */
  transformerForToWhile() {}

  /**
   * ++a
   */
  transformerIncToSet() {}

  /**
   * --a
   */
  transformerDecToSet() {}

  /**
   * +=a
   */
  transformerIncValToSet() {}

  /**
   * -=a
   */
  transformerDecValToSet() {}
}

module.exports = Transformer;
